package com.infocollect.project.api.ui;

import com.infocollect.project.api.entity.TappPageEntity;
import com.infocollect.project.api.service.ITappPageService;
import com.infocollect.project.api.vo.PackageInterfaceInfoVO;
import com.infocollect.project.form.vo.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * (TappOrgan)表控制层
 *
 * @author makejava
 * @since 2019-12-25 10:32:29
 */
@Api(value = "page", tags = "Api包管理")
@RestController
@RequestMapping("page")
public class TappPageController {
    @Autowired
    private ITappPageService pageService;

    @ApiOperation("获取包信息")
    @PostMapping("selectOne/{id}")
    @ResponseBody
    public R<Object> selectOne(@PathVariable(name = "id") Long id) {
        return R.newOk(this.pageService.queryById(id));
    }
    /**
     * 修改数据
     *
     * @param tappPageEntity 实例对象
     * @return 实例对象
     */
    @PostMapping("edit")
    @ResponseBody
    public R<Object> edit(TappPageEntity tappPageEntity) {
        pageService.update(tappPageEntity);
        return R.newOk();
    }

    /**
     * 新增数据
     *
     * @param tappPageEntity 实例对象
     * @return 实例对象
     */
    @PostMapping("add")
    @ResponseBody
    public R<String> add(@RequestBody TappPageEntity tappPageEntity) {
        return   pageService.insert(tappPageEntity);

    }
    /**
     * 删除包
     * @param id
     */
    @PostMapping("del")
    @ResponseBody
    public R<Object> deleteMapping(@RequestParam("id") Long id){
      pageService.deleteMapping(id);
      return R.newOk();
    }

    /**
     * 获取包信息
     * @return
     */
    @PostMapping("getPackageInterfaceInfo")
    @ResponseBody
    public R<List<PackageInterfaceInfoVO>> getPackageInterfaceInfo(){
     return R.newOk(pageService.getPackageInterfaceInfo());
    }
}
